<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/amazeui.min.css"/>
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/hy.admin.css"/>
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/jquery.confirm.css"/>
	</head>
	<body>
		<div class="am-g">
			 {include file='../Common/hy_header.html'}
      <div class="am-fl am-cf">
      	<p><span id="timeout" style="color:red;font-size:30px;">{$timeoutReal}</span>秒后刷新</p>
		<p style="font-size:20px;">2分钟前的浏览量:<strong style="font-size:25px;color:#0e90d2"> {$pv|default:'0'} </strong>
		登陆量:<strong style="font-size:25px;color:#0e90d2"> {$uv|default:'0'} </strong></p>
          <div class="am-btn-toolbar am-fl">
            <div class="am-btn-group am-btn-group-xs">
              <a  href="javascript:void(0);" onclick="clearNopass()" id="Nopass_html"  class="am-btn am-btn-default hy-js-href"><span class="am-icon-plus"></span> 清空未经过审核</a>
            </div>
          </div>
		  <div class="am-btn-toolbar am-fl">
            <div class="am-btn-group am-btn-group-xs">
              <a  href="javascript:void(0);" onclick="temCheckAll()" id="temCheckAll_html"  class="am-btn am-btn-default hy-js-href"><span class="am-icon-plus"></span> 勾选添加至实时审核</a>
            </div>
			<div class="am-btn-group am-btn-group-xs">
              <a  href="javascript:void(0);" onclick="refreshNow()" id="refresh_html"  class="am-btn am-btn-default hy-js-href"><span class="am-icon-plus"></span> 刷新</a>
            </div>
          </div>
	</div>
	</div>
      <div class="am-g">
      <div class="am-u-sm-12">
        <div class="am-form">
          <table class="am-table am-table-striped am-table-hover table-main">
            <thead>
              <tr>
              	<th width="10%" class="table-check"><input class="hy-js-selectall" type="checkbox" />全选/全不选</th>
				<th width="10%" class="table-type">昵称</th>
				<th width="40%" class="table-type">评论</th>
				<th width="10%" class="table-type">状态</th>
				<th width="10%" class="table-type">加精</th>
				<th width="10%" class="table-author">提交时间</th>
				<th width="15%" class="table-author">操作</th>
				
              </tr>
          </thead>
          <tbody>
          	   <!--{foreach key=key from=$sql_list item=sql}-->
            <tr>
              <td><input class="hy-js-id" name="ids" type="checkbox" data-temp-status="{$sql.status}"  value="{$sql.id}"/></td>
              <td onClick="checkedthis(this)">{$sql.nickname}</td>
              <td onClick="checkedthis(this)">{$sql.comment|default:" - "}</td>
			  <td onClick="checkedthis(this)">{$sql.statusShow|default:" - "}</td>
			  <td><input {if $sql.addStatus==1}checked=checked{/if} type="checkbox" onclick="addDigest({$sql.id},this)" name="addStatus"></td>
			  <td onClick="checkedthis(this)">{$sql.addtime|date_format:"Y-m-d"}</td>
     		  <td><div><div><a onclick="silence({$sql.wxid})" >禁止该用户发言    </a>{if $sql.status==6}<a onclick="temCheck('{$sql.id}')">临时审核{/if}<a data-param ="{ url:'index.php?g=admin&m=chat&a=delRecord&id={$sql.id}',hide:4}" class=" am-btn-xs am-text-danger hy-js-del" > 删除</a></div></div></td>
            </tr>
                  <!--{/foreach}-->  
          </tbody>
        </table>
          <div class="am-cf">

  <div class="am-fr">
  {$list_page}
  </div>
</div>
          <hr />
      
        </div>
      </div>

    </div>
    </div>
   {include file='../Common/hy_footer.html'}
   <script type="text/javascript" src="{$_C.hy_path}js/Map.js"></script>
   <script type="text/javascript" src="{$_C.hy_path}js/bin.select.js"></script>
   <script src="{$_C.hy_path}js/jquery.confirm.js"></script>
   <script type="text/javascript">
//   		var now = parseInt('{$now}');
//		var refresh = parseInt('{$refresh}');
//		var time = parseInt('{$time}');
//		var timeout = refresh-(now-time)%refresh;
	var now = parseInt('{$nowReal}');
	var timestamp = parseInt('{$timestampReal}');
	var refresh = parseInt('{$refreshtimeReal}');
	var timeout = refresh-(now-timestamp)%refresh;
		$(function(){
				inter = setInterval('countDown()',1000);
		})
		function checkedthis(params){
			if($(params).parent().find("input[name=ids]").attr("checked")!="checked"){
				$(params).parent().find("input[name=ids]").prop("checked","checked");
			}else{
				$(params).parent().find("input[name=ids]").prop('checked',"");
			}
		}
		function countDown(){
			timeout--;
			$("#timeout").html(timeout);
			if (timeout<=0) {
				clearInterval(inter);
				//window.history.go(0);
				window.location.href="index.php?g=admin&m=chat&a=library";
			}else{
				
			}
		}
	function refreshNow(){
		$("#refresh_html").html("<span class='am-icon-plus'></span> 刷新中...");
		parent.$('#library').attr('src', parent.$('#library').attr('src'));
	}
	function silence(wxid){
		jq_confirm("提醒","确定禁言该用户？",function(status){
			var data = {
				"status":status,
				"wxid":wxid
			}
			var url = "/ws/index.php?g=admin&m=chat&a=silenceUser";
			$.post(url,data,function(res){
				if(res.error==1){
						alert(res.content);
					}else{
						alert(res.content);
					}
			},"json")
		})
	}
	function jq_confirm(title,message,func){
				$.confirm({
				'title'		: title,
				'message'	: message,
				'buttons'	: {
					'禁言1小时'	: {
						'class'	: 'blue',
						'action': function(){
							func(1);
							$.confirm.hide();
						}
					},
					'禁言5天'	: {
						'class'	: 'blue',
						'action': function(){
							func(2);
							$.confirm.hide();
						}
					},
					'取消'	: {
						'class'	: 'gray',
						'action': function(){
							$.confirm.hide();
						}	// Nothing to do in this case. You can as well omit the action property.
					}
				}
			});
		}
	function clearNopass(){
		jq_confirm2("提醒","确定清空全部未经过审核数据？",function(){
			$("#Nopass_html").html("<span class='am-icon-plus'></span> 清理中...");
			var url = "/ws/index.php?g=admin&m=chat&a=clearNopass";
			$.post(url,"",function(data){
				if(data.error==0){
					//$('.bin-select-searchbtn').click();
					//window.history.go(0);
					window.location.href="index.php?g=admin&m=chat&a=library";
				}else{
					alert(data.content);
				}
			$("#Nopass_html").html("<span class='am-icon-plus'></span>  清空未审核");
			},'json');
		})
	}
	function jq_confirm2(title,message,func){
				$.confirm({
				'title'		: title,
				'message'	: message,
				'buttons'	: {
					'是'	: {
						'class'	: 'blue',
						'action': function(){
							func();
							$.confirm.hide();
						}
					},
					'否'	: {
						'class'	: 'gray',
						'action': function(){
							$.confirm.hide();
						}	// Nothing to do in this case. You can as well omit the action property.
					}
				}
			});
		}
		function addDigest(id,params){
			
				var url = "/ws/index.php?g=admin&m=chat&a=addDigest";
				var data={
					'id':id
				}
				$.post(url,data,function(res){
					if(res.error==0){
						//$('.bin-select-searchbtn').click();
					}else{
						params.checked=false;
						alert(res.content);
					}
				},'json');
		}
		function temCheck(id){
				var url = "/ws/index.php?g=admin&m=chat&a=temCheck";
				var data={
					'id':id
				}
				$.post(url,data,function(res){
					if(res.error==0){
						$('.bin-select-searchbtn').click();
					}else{
						alert(res.content);
					}
				},'json');
		}
		function temCheckAll(){
			$("#temCheckAll_html").html("<span class='am-icon-plus'></span> 勾选添加中...");
			var uids = '';
			var isCheck = true;
			if ($("input[name='ids']:checked").length > 0) {
				$("input[name='ids']:checked").each(function() {
					if($(this).attr("data-temp-status")!=6){
						isCheck = false;
					}else{
						uids += "," + $(this).val();
					}
				})
				if(isCheck){
					uids = uids.substring(1);
				}else{
					$("#temCheckAll_html").html("<span class='am-icon-plus'></span> 勾选添加至实时审核");
					alert("请选择未经审核的数据");
					return;
				}
			} else {
				$("#temCheckAll_html").html("<span class='am-icon-plus'></span> 勾选添加至实时审核");
				alert("请勾选需要临时添加至实时审核的未经审核数据");
				return;
			}
				var url = "/ws/index.php?g=admin&m=chat&a=temCheck";
				var data={
					'id':uids
				}
				$.post(url,data,function(res){
					if(res.error==0){
						window.location.href="index.php?g=admin&m=chat&a=library";
					}else{
						alert(res.content);
					}
					$("#temCheckAll_html").html("<span class='am-icon-plus'></span> 勾选添加至实时审核");
				},'json');
		}
   </script>
	</body>
</html>
